home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 8
/
Night Owl CD-ROM (NOPV8) (Night Owl Publisher) (1993).ISO
/
047a
/
lex_yacc.arj
/
LENGS.L
< prev
next >
Wrap
Text File
|
1989-05-28
|
653b
|
26 lines
{ Counts word lengths in a file (normally, input is taken from the
console; use input redirection to input a file), and prints out
a histogram of word lengths.
This is a Turbo Pascal Lex version of a UNIX Lex program, discussed in
the (SUN) UNIX Lex manual, section 7.8. }
uses LexLib;
var lengs : array [1..100] of integer;
%%
[a-zA-Z]+ inc(lengs[yyleng]);
. |
\n ;
%%
var i : integer;
begin
for i := 1 to 100 do
lengs[i] := 0;
if yylex=0 then
begin
writeln('Length No. words');
for i := 1 to 100 do
if lengs[i]>0 then
writeln(i, ' ', lengs[i]);
end
end.